package leetcode.array;

import java.util.Arrays;

public class Dedup {
    public static int removeDuplicates(int[] nums) {
        int j = 0;
        for (int i = 1; i < nums.length; i++) {
            if (nums[i] != nums[j]) {
                j++;
                nums[j] = nums[i];
            }
        }
        System.out.println(Arrays.toString(nums));
        return j + 1;
    }

    public static void main(String[] args) {
        int len = removeDuplicates(new int[]{0, 0, 1, 1, 1, 2, 2, 3, 3, 4});
        System.out.println("length:" + len);

    }
}
